<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>abs</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">Standard C Math</a> &gt; <a href="abs.html">abs</a>
  </div>

  <div class="name-format">
    abs
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;stdlib.h&gt;
  int abs( int num );
</pre>

  <p>The abs() function returns the absolute value of <em>num</em>. For
  example:</p>
  <pre class="example-code">
   int magic_number = 10;
   cout &lt;&lt; &quot;Enter a guess: &quot;;
   cin &gt;&gt; x;
   cout &lt;&lt; &quot;Your guess was &quot; &lt;&lt; abs( magic_number - x ) &lt;&lt; &quot; away from the magic number.&quot; &lt;&lt; endl;          
</pre>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="fabs.html">fabs</a><br>
    <a href="labs.html">labs</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
